package com.dynabook.ems.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum MailEnum {

    FLOW("FLOW", "flow"),
    IMPORT("IMPORT", "import"),
    APPLY("APPLY", "apply"),
    REJECT("REJECT", "reject"),
    RECEIPT("RECEIPT", "receipt"),
    CHECK("CHECK", "check"),
    WORK_ORDER_APPROVAL("WORK_ORDER_APPROVAL", "work_order_approval"),
    WORK_ORDER_BATCH_REJECT("WORK_ORDER_BATCH_REJECT", "work_order_batch_reject"),
    WORK_ORDER_BATCH_APPROVE("WORK_ORDER_BATCH_APPROVE", "work_order_batch_approve"),
    WORK_ORDER_PM_COMPLETE("WORK_ORDER_PM_COMPLETE", "work_order_pm_complete"),
    WORK_ORDER_SAMPLE_ACCEPTANCE("WORK_ORDER_SAMPLE_ACCEPTANCE", "work_order_sample_acceptance"),
    ;
    private final String text;

    private final String value;

    MailEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static MailEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (MailEnum anEnum : MailEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
